/*common*/
var {
  PI,
  random,
  atan2,
  sqrt,
  pow,
  sin,
  cos
} = Math;
// 随机数
function rnd(n,m){
  return parseInt(random()*(m-n)+n)
}
// 角度
function d2a(d){
  return d/180*PI;
}
function a2d(a){
  return a*180/PI;
}
function clear(ctx){
  ctx.clearRect(0,0,canvas.width,canvas.height)
}
// 资源加载
function loadResources( arr, callback, loading){
  var count = 0;
  // 网的音乐
  // netMusic = new Audio();
  // netMusic.src = "https://v.superour.com/addons/weisrc_dish/template/mobile/style1/assets/fish/audio/net.mp3";
  // document.addEventListener("WeixinJSBridgeReady",function(){
  //   netMusic.play();
  //   netMusic.pause();
  // },false);
  // netMusic.load();
  // // 背景音乐
  // bgMusic = new Audio();
  // bgMusic.src = 'https://v.superour.com/addons/weisrc_dish/template/mobile/style1/assets/fish/audio/bg2.mp3';
  // document.addEventListener("WeixinJSBridgeReady",function(){
  //   bgMusic.play();
  // },false);
  // bgMusic.load();

  arr.forEach(function( imageSrc, index ){
    var oImage = new Image();
    oImage.src = `img/${imageSrc}.png`;
    oImage.onload = function(){
      count++;
      imageData[imageSrc] = oImage;
      loading&&loading(count,arr.length);
      if( count == arr.length){
        callback && callback();
      }
    }
  })
}

